package org.htmlparser.nodes;

import org.htmlparser.Remark;
import org.htmlparser.lexer.Cursor;
import org.htmlparser.lexer.Page;
import org.htmlparser.util.ParserException;
import org.htmlparser.visitors.NodeVisitor;

public class RemarkNode extends AbstractNode
  implements Remark
{
  protected String mText;

  public RemarkNode(String paramString)
  {
    super(null, 0, 0);
    setText(paramString);
  }

  public RemarkNode(Page paramPage, int paramInt1, int paramInt2)
  {
    super(paramPage, paramInt1, paramInt2);
    this.mText = null;
  }

  public void accept(NodeVisitor paramNodeVisitor)
  {
    paramNodeVisitor.visitRemarkNode(this);
  }

  public String getText()
  {
    String str;
    int i;
    int j;
    if (this.mText == null)
    {
      i = 4 + super.getStartPosition();
      j = super.getEndPosition() - 3;
      if (i >= j)
        str = "";
    }
    while (true)
    {
      while (true)
      {
        return str;
        str = this.mPage.getText(i, j);
      }
      str = this.mText;
    }
  }

  public void setText(String paramString)
  {
    this.mText = paramString;
    if ((paramString.startsWith("<!--")) && (paramString.endsWith("-->")))
      this.mText = paramString.substring(4, paramString.length() - 3);
    this.nodeBegin = 0;
    this.nodeEnd = this.mText.length();
  }

  public String toHtml(boolean paramBoolean)
  {
    String str;
    if (this.mText == null)
      str = this.mPage.getText(super.getStartPosition(), super.getEndPosition());
    while (true)
    {
      return str;
      StringBuffer localStringBuffer = new StringBuffer(7 + this.mText.length());
      localStringBuffer.append("<!--");
      localStringBuffer.append(this.mText);
      localStringBuffer.append("-->");
      str = localStringBuffer.toString();
    }
  }

  public String toPlainTextString()
  {
    return "";
  }

  public String toString()
  {
    Cursor localCursor1;
    int i = super.getStartPosition();
    int j = super.getEndPosition();
    StringBuffer localStringBuffer = new StringBuffer(20 + j - i);
    if (this.mText == null)
    {
      localCursor1 = new Cursor(super.getPage(), i);
      Cursor localCursor2 = new Cursor(super.getPage(), j);
      localStringBuffer.append("Rem (");
      localStringBuffer.append(localCursor1);
      localStringBuffer.append(",");
      localStringBuffer.append(localCursor2);
      localStringBuffer.append("): ");
      localCursor1.setPosition(i + 4);
      int k = j - 3;
      if (localCursor1.getPosition() < k);
    }
    try
    {
      char c1;
      label171: int l;
      do
      {
        c1 = this.mPage.getCharacter(localCursor1);
        switch (c1)
        {
        case '\11':
        case '\f':
        default:
          localStringBuffer.append(c1);
        case '\t':
        case '\n':
        case '\r':
        }
      }
      while (77 > localStringBuffer.length());
      localStringBuffer.append("...");
      do
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return localStringBuffer.toString();
              localStringBuffer.append("\\t");
            }
            localStringBuffer.append("\\n");
          }
          localStringBuffer.append("\\r");
        }
        localStringBuffer.append("Rem (");
        localStringBuffer.append(i);
        localStringBuffer.append(",");
        localStringBuffer.append(j);
        localStringBuffer.append("): ");
        l = 0;
      }
      while (l >= this.mText.length());
      char c2 = this.mText.charAt(l);
      switch (c2)
      {
      case '\11':
      case '\f':
      default:
        localStringBuffer.append(c2);
      case '\t':
      case '\n':
      case '\r':
      }
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              if (77 > localStringBuffer.length())
                break label372;
              localStringBuffer.append("...");
            }
            localStringBuffer.append("\\t");
          }
          localStringBuffer.append("\\n");
        }
        localStringBuffer.append("\\r");
      }
      label372: ++l;
    }
    catch (ParserException localParserException)
    {
      break label171:
    }
  }
}